package com.corpgovernment.organization.dataloader.db;

import com.corpgovernment.organization.entity.db.MbUserLogin;
import com.corpgovernment.organization.mapper.MbUserLoginMapper;
import com.ctrip.corp.obt.generic.utils.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author jhxue
 * @create 2022-02-18-16:14
 */
@Component
public class MbUserLoginLoader {

	@Autowired
	private MbUserLoginMapper userLoginMapper;

	public List<MbUserLogin> selectByRecord(MbUserLogin record) {
		if (record == null) {
			return new ArrayList<>();
		}
		return userLoginMapper.select(record);
	}

	public MbUserLogin selectOneByRecord(MbUserLogin record) {
		List<MbUserLogin> mbUserLogins = this.selectByRecord(record);
		if (CollectionUtils.isEmpty(mbUserLogins)) {
			return null;
		}
		return mbUserLogins.get(0);
	}
}
